class HistoryManager {
public:
    struct MeshState {
        MeshData meshData;
        double quality;
        std::string description;
        QDateTime timestamp;
    };

    // 保存当前状态
    void saveState(const MeshData& mesh, const std::string& description) {
        MeshState state;
        state.meshData = mesh;
        state.quality = MeshQuality::evaluateOverallQuality(mesh);
        state.description = description;
        state.timestamp = QDateTime::currentDateTime();
        
        m_history.push_back(state);
        
        if (m_history.size() > m_maxHistorySize) {
            m_history.pop_front();
        }
    }

    // 回退到指定状态
    bool revertTo(int stateIndex, MeshData& mesh) {
        if (stateIndex >= 0 && stateIndex < m_history.size()) {
            mesh = m_history[stateIndex].meshData;
            return true;
        }
        return false;
    }

private:
    std::deque<MeshState> m_history;
    const size_t m_maxHistorySize = 20;
}; 